//
//  ZLotteryHallController.m
//  Zlottery
//
//  Created by HuaYingJiTuan on 16/1/8.
//  Copyright © 2016年 张庆庆. All rights reserved.
//

#import "ZLotteryHallController.h"
#import "UIImage+Ex.h"
#import "UIView+EX.h"
@interface ZLotteryHallController ()

@property (weak, nonatomic) IBOutlet UIBarButtonItem *active;
@property (nonatomic, weak) UIView *coverView;
@property (nonatomic, weak) UIImageView *imageView;
@end

@implementation ZLotteryHallController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *imageName = @"CS50_activity_image";
    self.active.image = [UIImage originalImge:imageName];
}
- (IBAction)activeClick:(id)sender {
    //
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    
    UIView *converView = [[UIView alloc]initWithFrame:window.bounds];
    [window addSubview:converView];
    self.coverView = converView;
    converView.backgroundColor = [UIColor blackColor];
    converView.alpha = 0.5;
    
    //创建图片
    UIImage *img = [UIImage imageNamed:@"aa"];
    UIImageView *imageView = [[UIImageView alloc]init];
    self.imageView = imageView;
    imageView.image = img;
    
    [imageView sizeToFit];
    imageView.center = self.view.center;
    
    imageView.y -= 64;
    [window addSubview:imageView];
    imageView.userInteractionEnabled = YES;
    //关闭按钮
    UIButton *closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [imageView addSubview:closeBtn];
    [closeBtn setImage:[UIImage imageNamed:@"alphaClose"] forState:UIControlStateNormal];
    [closeBtn sizeToFit];
    closeBtn.x = imageView.width- closeBtn.width;
    closeBtn.y = 0;
    
    [closeBtn addTarget:self action:@selector(closeBtnClick) forControlEvents:UIControlEventTouchUpInside];
}

- (void)closeBtnClick{
    [UIView animateWithDuration:1 animations:^{
        self.coverView.alpha = 0;
        self.imageView.frame = CGRectMake(40, 50, 0, 0);
        [self.imageView.subviews[0] setBounds:CGRectMake(0, 0, 0, 0)];
    } completion:^(BOOL finished) {
        [self.coverView removeFromSuperview];
        [self.imageView removeFromSuperview];
    }];
}
#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Incomplete implementation, return the number of sections
    return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete implementation, return the number of rows
    return 0;
}


@end
